// pages/xiangq/xiangq.js
import http from '../../common/http'
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
	  img:[
		'../../imgs/b1.jpg',
		'../../imgs/b2.jpg',
		'../../imgs/b3.jpg',
		'../../imgs/b4.jpg',
		'../../imgs/b5.jpg'
	],
	list:[],
	page:1,
	listId:''
	},
  
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(e) {
	//   console.log(e);
	  let _this=this;
	  wx.request({
		url: 'https://route.showapi.com/1700-2',
		method:'get',
		data:{'showapi_appid':1367085,
		'showapi_sign':'cb8507c33e4a43cfa34a954c91b91fd6',
		'classifyId':e.id
	  },
		header:{'Content-type':'application/json'},
		success(res){
			console.log(res.data.showapi_res_body.contentlist);
		  _this.setData({list:res.data.showapi_res_body.contentlist})
		  // 修改navigationBarTitleText
			wx.setNavigationBarTitle({
				title:`${e.title}`
			})
		//   console.log(_this.data.list);
		},
		fail(err){
			console.log(err);
		},
	  })
	},
	goShow(e){
        console.log(e);
        wx.navigateTo({
          url: '../show/show?id='+e.currentTarget.dataset.id +'&title='+e.currentTarget.dataset.title,
        })
    },
    onReachBottom(){
        this.data.page++;
        let listMsg = {
            url:'/1700-2',
            data:{
                'showapi_appid':1367085,
                "showapi_sign":'cb8507c33e4a43cfa34a954c91b91fd6',
                'classifyId':this.data.listId,
                'page':this.data.page
            }
        }
        http(listMsg).then((res)=>{
            let lists = this.data.list.concat(res.data.showapi_res_body.contentlist)
            this.setData({
                list:lists
            });
        })
    },
  })